package net.zjitc.service.impl;

import net.zjitc.dao.AdminCateGoryDao;
import net.zjitc.dao.AdminCateGorySecondDao;
import net.zjitc.dao.impl.AdminCateGoryDaoImpl;
import net.zjitc.dao.impl.AdminCateGorySecondDaoImpl;
import net.zjitc.pojp.CateGory;
import net.zjitc.pojp.CateGorySecond;
import net.zjitc.service.AdminCateGorySecondService;
import net.zjitc.service.AdminCateGoryService;
import org.apache.log4j.Category;

import java.util.List;

/**
 * Created by lenovo on 2017/11/15.
 */
public class AdminCateGoryServiceImpl implements AdminCateGoryService {
   AdminCateGoryDao dao=new AdminCateGoryDaoImpl();
   AdminCateGorySecondDao csdao=new AdminCateGorySecondDaoImpl();
   //查询所有的一级分类
    public List<CateGory> findOneList() {
        List<CateGory> list=dao.findOneList();
        //通过每个一级分类查出相关的所有的二级分类，并设置为一级分类的成员，为页面显示准备
        for(CateGory c:list){
            List<CateGorySecond> cslist=csdao.findByCid(c.getCid());
            c.setCateGorySecoondList(cslist);
        }
        return list;
    }

    public int insert(CateGory cateGory) {
        return dao.insert(cateGory);
    }

    public CateGory findByCid(String cid) {
        return dao.findByCid(cid);
    }

    public int update(CateGory cateGory) {
        return dao.update(cateGory);
    }

}
